<?php

namespace iBrand\Store\Backend\Model;

use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use iBrand\Component\Goods\Models\GoodsModel;
use iBrand\Component\Goods\Models\Attribute;

class Models extends GoodsModel implements Transformable
{
	use TransformableTrait;

	protected $guarded = ['id'];

	public function setSpecIdsAttribute($value)
	{
		$this->attributes['spec_ids'] = implode(',', $value);
	}

	public function getSpecIdsAttribute($value)
	{
		return explode(',', $value);
	}

	public function attribute()
	{
		return $this->hasMany(Attribute::class, 'model_id');
	}

}
